
{extend name="index/index" /}
{block name="index"}
<head>
    <link rel="stylesheet" href="/static/admin/assets/css/toastr.min.css">
    <!-- <link rel="stylesheet" href="/static/admin/assets/css/bootstrap.min.css"> -->
  <style>
    .pagination{
    float: left;
    margin: 10px;
    }
    .namefile{width: 250px;
    height: 30px;
    border-radius: 4px;
    border: 1px solid #ccc;}
</style>
</head>
        <div class="tpl-content-wrapper">
            <div class="tpl-content-page-title">
                被禁用的管理员
            </div>
            <ol class="am-breadcrumb">
                <li><a href="{:url('admin/index/index')}" class="am-icon-home">首页</a></li>
                <!-- <li><a href="#">Amaze UI CSS</a></li> -->
                <li class="am-active">被禁用的管理员</li>
            </ol>
            <div class="tpl-portlet-components">
                <div class="portlet-title">
                    <div class="caption font-green bold">
                    </div>
                    <div class="tpl-portlet-input tpl-fz-ml">
                    </div>
                </div>
                <div class="tpl-block">
                    <div class="am-g">
                        <div class="am-u-sm-12 am-u-md-6">
                            <div class="am-btn-toolbar">
                            </div>
                        </div>
                        <div class="am-u-sm-12 am-u-md-3">
                            <div class="am-input-group am-input-group-sm">
                                <form action="{:url('admin/User/index')}">
                                    <input type="text" name="title" class="am-form-field" style="width: 185px" placeholder="请输入姓名">
                                    <span class="am-input-group-btn">
                                        <button class="am-btn  am-btn-default am-btn-success tpl-am-btn-success am-icon-search" type="submit"></button>
                                    </span>
                                </form>
                            </div>
                        </div>
                    </div>
                    <div class="am-g">
                        <div class="am-u-sm-12">
                            <form class="am-form">
                                <table class="am-table am-table-striped am-table-hover table-main">
                                    <thead>
                                        <tr>
                                            <th class="table-id">ID</th>
                                            <th class="table-title">姓名</th>
                                            <th class="table-title">电话</th>
                                            <th class="table-type">性别</th>
                                            <!-- <th class="table-author am-hide-sm-only"></th> -->
                                            <!-- <th class="table-date am-hide-sm-only">权限</th> -->
                                            <th class="table-set">操作</th>
                                            <th class="table-set">角色</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                      {empty name="data"}
                                      <tr><td colspan="6" align="center">暂无数据</td></tr>
                                      {else /}
                                        {volist name="data" id="v"}
                                        <tr>
                                            <td>{$v['id']}</td>
                                            <td>{$v['name']}</td>
                                            <td>{$v['tel']}</td>
                                            {if condition="$v.sex eq 1"}
                                            <td><font color="green" size="2"><strong>男</strong></font></td>
                                            {else /}
                                            <td><font color="red"><strong>女</strong></font></td>
                                            {/if}</td>

                                            <td>
                                                <div class="am-btn-toolbar">
                                                    <div class="am-btn-group am-btn-group-xs">
                                                        {if condition="$v.name == '王川平'"}
                                                        <a href="javascript:void(0);" class="am-btn am-btn-default am-btn-xs am-text-secondary jy" style="color: #ccc;background:white"  title="无权访问">
                                                            <span class="am-icon-pencil-square-o"></span>编辑</a>
                                                        {else /}
                                                        <a href="javascript:void(0);" class="am-btn am-btn-default am-btn-xs am-text-secondary edit " style="background: white;color:skyblue" user-id="{$v['id']}" onclick="edit_user()">
                                                            <span class="am-icon-pencil-square-o"></span>编辑</a>
                                                        {/if}
                                                        {if condition="$v.name == '王川平'"}
                                                        <a href="javascript:void(0);" class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only jy" style="color: #ccc;background:white" title="无权访问">禁用</a>
                                                        {else /}

                                                            {if condition="$v.status eq 1"}
                                                            <a href="javascript:void(0);" class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only jy" style="color: red;background:white" onclick="status(this,'{$v['id']}')" title="禁用">禁用</a>
                                                            {else /}
                                                            <a href="javascript:void(0);" class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only" style="color: red;background:white" onclick="status(this,'{$v['id']}')" title="启用">启用</a>
                                                            {/if}
                                                        {/if}
                                                        <a href="{:url('admin/User/role', ['id'=>$v['id']])}" class="am-btn am-btn-default am-btn-xs am-hide-sm-only" style="background:white"><span class="am-icon-copy"></span>分配角色</button></a>

                                                    </div>
                                                </div>
                                            </td>
                                            <td></td>
                                        </tr>
                                        {/volist}
                                      {/empty}
                                    </tbody>
                                </table>
                                <div class="am-cf">
                                    <div class="am-fr">
                                        {$page}
                                    </div>
                                </div>
                                <hr>

                            </form>
                        </div>

                    </div>
                </div>
                <div class="tpl-alert"></div>
            </div>

        </div>

    <script src="/static/admin/assets/js/toastr.min.js"></script>
    <script src="/static/admin/assets/js/jquery.min.js"></script>
    <script src="/static/admin/assets/js/jquery-1.8.3.min.js"></script>
    <script src="/static/admin/assets/js/jquery-1.8.3.min.js"></script>
    <!-- <script src="/static/admin/assets/js/bootstrap.min.js"></script> -->
    <script src="/static/admin/assets/js/my.js"></script>


<!-- 修改模态框 -->
<div id="modal1" class="modal">
  <div class="modal-content">
    <header class="modal-header">
      <h2 style="margin:0px auto;font-size: 25px" class="user_h2">&nbsp;&nbsp;&nbsp;</h2>
      <span class="close1">×</span>
    </header>
    <div class="modal-body">
      <!-- <form action="{:url('index/Login/index')}" method="post" onsubmit="return login()"> -->
      <form id="form_edit" method="post">
        <table align="center" style="margin-left: 150px;">
            <tr>
              <input type="hidden" name="id" id="user_id">
              <td>姓名:</td>
              <td><input type="text" name="name" id="user_name1" class="namefile" onblur="matchName()" /></td>
              <td id="name" style="color:#757575"></td>
            </tr>
            <tr height="10"></tr>
            <tr style="margin-top: 20px;">
              <td>原密码密码:</td>
              <td><input type="password" name="ypass" id="match1" class="namefile" onblur="matchPass()" />
                <input type="hidden" id="match2" class="namefile" uid=""/></td>
              <td id="ytab" style="color:#757575"></td>
            </tr>
            <tr style="margin-top: 20px;">
              <td>新密码:</td>
              <td><input type="password" name="pass" id="pass1" class="namefile" onblur="checkPass()" /></td>
              <td id="ptab" style="color:#757575"></td>
            </tr>
            <tr style="margin-top: 20px;">
              <td>重复密码:</td>
              <td><input type="password" name="repass" class="namefile" onblur="checkPass()" /></td>
              <td id="rptab" style="color:#757575"></td>
            </tr>
            <tr height="10"></tr>
            <tr>
              <td>电话:</td>
              <td><input type="text" name="tel" id="telemail1" class="namefile" onblur="telEmail()" /></td>
              <td id="etab" style="color:#757575"></td>
            </tr>
            <tr height="10"></tr>
            <tr>
              <td>年龄:</td>
              <td><input type="text" name="age" id="user_age1" class="namefile" onblur="checkAge()" /></td>
              <td id="age" style="color:#757575"></td>
            </tr>
            <tr height="10"></tr>
            <tr>
              <td>地址:</td>
              <td><input type="text" name="province" id="province1" class="namefile" onblur="" /></td>
              <td id="province" style="color:#757575"></td>
            </tr>
            <tr height="10"></tr>
        </table>
    </div>
      <footer class="modal-footer">
        <div id="cancel1" class="cancel">取消</div>
        <div id="cancel1" class="cancel" onclick="edit_save()">保存</div>
      </footer>
      </form>
  </div>
</div>


<!-- 分配角色模态框 -->
<div id="modal2" class="modal">
  <div class="modal-content">
    <header class="modal-header">
      <h2 style="margin:0px auto;font-size: 25px" class="user_h2">&nbsp;&nbsp;&nbsp;</h2>
      <span class="close2">×</span>
    </header>
    <div class="modal-body">
      <!-- <form action="{:url('index/Login/index')}" method="post" onsubmit="return login()"> -->
      <form id="form_edit" method="post">
        <table align="center" style="margin-left: 150px;">
            <tr>
              <input type="hidden" name="id" id="user_id">
              <td>姓名:</td>
              <td><input type="text" name="name" id="user_name1" class="namefile" onblur="matchName()" /></td>
              <td id="name" style="color:#757575"></td>
            </tr>
            <tr height="10"></tr>
            <tr style="margin-top: 20px;">
              <td>原密码密码:</td>
              <td><input type="password" name="ypass" id="match1" class="namefile" onblur="matchPass()" />
                <input type="hidden" id="match2" class="namefile" uid=""/></td>
              <td id="ytab" style="color:#757575"></td>
            </tr>
            <tr style="margin-top: 20px;">
              <td>新密码:</td>
              <td><input type="password" name="pass" id="pass1" class="namefile" onblur="checkPass()" /></td>
              <td id="ptab" style="color:#757575"></td>
            </tr>
            <tr style="margin-top: 20px;">
              <td>重复密码:</td>
              <td><input type="password" name="repass" class="namefile" onblur="checkPass()" /></td>
              <td id="rptab" style="color:#757575"></td>
            </tr>
            <tr height="10"></tr>
            <tr>
              <td>电话:</td>
              <td><input type="text" name="tel" id="telemail1" class="namefile" onblur="telEmail()" /></td>
              <td id="etab" style="color:#757575"></td>
            </tr>
            <tr height="10"></tr>
            <tr>
              <td>年龄:</td>
              <td><input type="text" name="age" id="user_age1" class="namefile" onblur="checkAge()" /></td>
              <td id="age" style="color:#757575"></td>
            </tr>
            <tr height="10"></tr>
            <tr>
              <td>地址:</td>
              <td><input type="text" name="province" id="province1" class="namefile" onblur="" /></td>
              <td id="province" style="color:#757575"></td>
            </tr>
            <tr height="10"></tr>
        </table>
    </div>
      <footer class="modal-footer">
        <div id="cancel2" class="cancel">取消</div>
        <div id="cancel2" class="cancel" onclick="save_role()">保存</div>
      </footer>
      </form>
  </div>
</div>


<!-- 管理员禁用 -->
    <script>
            function status(obj,id){


                $.ajax({
                    url:"admin_status",
                    Type:'get',
                    data:{id:id},
                    dataType:'json',
                    success:function(data){

                      if (data.status) {
                          // modal1.style.display = "none";
                          toastr.success(data.msg);
                          window.location.reload();

                      } else {
                          toastr.error(data.msg);
                      }

                    },
                    error:function(data){
                        toastr.error('系统故障,请联系管理员');
                    }
                });
            }
    </script>


<!-- 提交修改数据 -->
    <script>
            function edit_save(){
              var data = $('#form_edit').serialize();
              console.log(data);

                $.ajax({
                    url:"updataUser",
                    Type:'post',
                    data:data,
                    dataType:'json',
                    success:function(data){
                      // window.location.reload();

                      if (data.status) {
                          // modal1.style.display = "none";
                          toastr.success(data.msg);
                          window.location.reload();

                      } else {
                          toastr.error(data.msg);
                      }

                    },
                    error:function(data){

                        toastr.error('系统故障,请联系管理员');
                    }
                });
            }

    </script>

    <script>

// 新增管理员
    var btn = document.getElementById('showModel');
    var close = document.getElementsByClassName('close')[0];
    var cancel = document.getElementById('cancel');
    var modal = document.getElementById('modal');

    btn.addEventListener('click', function(){
        modal.style.display = "block";
    });


    close.addEventListener('click', function(){
        modal.style.display = "none";
    });

    cancel.addEventListener('click', function(){
        modal.style.display = "none";
    });

// 编辑管理员
    // var btn1 = document.getElementById('showModel1');
    var close1 = document.getElementsByClassName('close1')[0];
    var cancel1 = document.getElementById('cancel1');
    var modal1 = document.getElementById('modal1');


    
    function edit_user(){
        // console.log(1111111);
        modal1.style.display = "block";
    }


    close1.addEventListener('click', function(){
        modal1.style.display = "none";
    });

    cancel1.addEventListener('click', function(){
        modal1.style.display = "none";
    });




    function telEmail(){

      // console.log(111);
        var email = document.getElementById('telemail').value;
        var etab = document.getElementById('etab');

            if (/^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\d{8}$/.test(email)) {
                etab.innerHTML = ' *手机号码通过验证';
                etab.style.color = '#0a0';

                return true;
            }else{
                etab.innerHTML = ' *手机格式不正确!';
                etab.style.color = '#f00';
                return false;
            }
    }

    function checkUser(){

        var user_name = document.getElementById('user_name').value;
        var name = document.getElementById('name');

        if (user_name == ''){
              name.innerHTML = ' *用户名不能为空!';
              name.style.color = '#f00';
              return false;
          }else{
              name.innerHTML = ' *通过验证';
              name.style.color = '#0a0';
              return true;
        }
    }

    function checkPass(){

        var pass = document.getElementById('pass').value;
        var ptab = document.getElementById('ptab');

        if (pass == null){

              rptab.innerHTML = ' *密码不能为空!';
              rptab.style.color = '#f00';
              return false;

        }else{

          if (pass.length < 6 || pass.length > 12) {
              ptab.innerHTML = ' *密码长度不合法!';
              ptab.style.color = '#f00';
              return false;

          } else {

              ptab.innerHTML = ' *通过验证';
              ptab.style.color = '#0a0';
              return true;

          }

        }
    }

    function checkAge(){

        var user_age = document.getElementById('user_age').value;
        var age = document.getElementById('age');

        if (user_age == null){
              user_age.innerHTML = ' *年龄不能为空!';
              user_age.style.color = '#f00';
              return false;
        }

        if (/^(?:[1-9][0-9]?|1[01][0-9]|120)$/.test(user_age)) {
            age.innerHTML = ' *年龄通过验证';
            age.style.color = '#0a0';

        }else{
            age.innerHTML = ' *年龄格式不正确';
            age.style.color = '#f00';
            return false;
        }
    }

  </script>

{/block}
